/**
 * 
 */
package rest_ws;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.FormParam;

import jpa_objects.Event_suggestion;
import jpa_objects.Instructor;
import jpa_objects.Player;
import jpa_objects.Sport;
import jpa_objects.Sport_calification;
import json_objects_received.JaxPlayerClases;
import json_objects_send.Basic_User;
import json_objects_send.Friend_request;
import json_objects_send.Full_Player;
import json_objects_send.Full_User;
import json_objects_send.JSON_event_suggestion;
import json_objects_send.JSON_instructor;
import logic.CluviePlayer;



/**
 * @author Alejandro Casas
 * 
 *
 */
@Path("/player")
public class RestPlayerWS {
	
	
	
	@POST
	@Path(value="GetSuggestedInstructors")
	@Produces(MediaType.APPLICATION_JSON)
	public List<Basic_User> GetSuggestedInstructors(final json_objects_received.JaxPlayerClases.GetSuggestedInstructors 
			param)
	{
		return new CluviePlayer().getSuggestedInstructors(param.getMail());
	}
	
	@POST
	@Path(value="RegisterPlayer")
	@Produces(MediaType.APPLICATION_JSON)
	public Basic_User RegisterPlayer(final json_objects_received.RegisterPlayer info)
	{
		System.out.println(info.getMail()+","+ info.getBirthday()+","+info.getMail()+","+ 
				info.getGender()+","+info.getCountry()+","+info.getCity()+","+info.getSports());
		return new CluviePlayer().registerPlayer(info.getName(), info.getBirthday(), info.getMail(), 
				info.getGender(), info.getPass(),info.getCountry(),info.getCity(),info.getSports());
	}
	@POST
	@Path(value="SendEventParticipationRequest")
	@Produces(MediaType.APPLICATION_JSON)
	public boolean SendEventParticipationRequest (final json_objects_received.JaxPlayerClases.SendEventParticipationRequest	param)
	{
		return new CluviePlayer().sendEventParticipationRequest(param.getMail(), param.getEventId());
	}
	
	
	@POST
	@Path(value="SendCoachingRequest")
	@Produces(MediaType.APPLICATION_JSON)
	public boolean SendCoachingRequest(final json_objects_received.JaxPlayerClases.SendCoachingRequest	param)
	{
		return new CluviePlayer().sendCoachingRequest(param.getMailFrom(), param.getMailTo());
	}
	@POST
	@Path(value="SendFriendRequest")
	@Produces(MediaType.APPLICATION_JSON)
	public boolean SendFriendRequest(final json_objects_received.JaxPlayerClases.SendFriendRequest	param)
	{
		return new CluviePlayer().sendFriendRequest(param.getMailFrom(), param.getMailTo());
	}
	
	@POST
	@Path(value="Accept_friend_request")
	@Produces(MediaType.APPLICATION_JSON)
	public boolean Accept_friend_request(final json_objects_received.JaxPlayerClases.Accept_friend_request	param)
	{
		return new CluviePlayer().accept_friend_request(param.getMailFrom(), param.getMailTo());
	}
	
	@POST
	@Path(value="Reject_friend_request")
	@Produces(MediaType.APPLICATION_JSON)
	public boolean Reject_friend_request(final json_objects_received.JaxPlayerClases.Reject_friend_request	param)
	{
		return new CluviePlayer().reject_friend_request(param.getMailFrom(), param.getMailTo());
	}
	
	
	@POST
	@Path(value="GetFriendRequests")
	@Produces(MediaType.APPLICATION_JSON)
	public List<Friend_request> GetFriendRequests(final json_objects_received.JaxPlayerClases.GetFriendRequests	param)
	{
		return new CluviePlayer().getFriendRequests(param.getMail());
	}
	
	@POST
	@Path(value="SetPlayerAvailable")
	@Produces(MediaType.APPLICATION_JSON)
	public boolean SetPlayerAvailable(final json_objects_received.SetPlayerAvailable	param)
	{
		return new CluviePlayer().setPlayerAvailable(param.getMail(), param.getStartDate(), param.getEndDate(), param.isPrivacy(), 
				param.getSports(),param.getLat(),param.getLng(),param.getCountry(),param.getCity());
	}
	@POST
	@Path(value="SetPlayerUnavailable")
	@Produces(MediaType.APPLICATION_JSON)
	public boolean SetPlayerUnavailable(final json_objects_received.JaxPlayerClases.SetPlayerUnavailable	param)
	{
		return new CluviePlayer().setPlayerUnavailable(param.getMail());
	}
	/*TODO REPENSAR
	@POST
	@Path(value="EditPlayerProfile")
	@Produces(MediaType.APPLICATION_JSON)
	public Full_User EditPlayerProfile(final json_objects_received.JaxPlayerClases.EditPlayerProfile	param)
	{
		return new CluviePlayer().editPlayerProfile(mail, description, country, city, picture, phone, carrier);
	}
	*/
	@POST
	@Path(value="GetPlayerInstructors")
	@Produces(MediaType.APPLICATION_JSON)
	public List<JSON_instructor> GetPlayerInstructors(final json_objects_received.JaxPlayerClases.GetPlayerInstructors	param)
	{
		return new CluviePlayer().getPlayerInstructors(param.getMail(),param.getViewer());
	}
	@POST
	@Path(value="GetEventSuggestions")
	@Produces(MediaType.APPLICATION_JSON)
	public List<JSON_event_suggestion> GetEventSuggestions(final json_objects_received.JaxPlayerClases.GetEventSuggestions	param)
	{
		return new CluviePlayer().getEventSuggestions(param.getMail());
	}
}
